# 查看消息提醒————getSignMsg
@app.route("/getSignMsg", methods=['GET'])
def getSignMsg():
    openid = request.args.get("openid")
    data = {}
    sign = []
    psign = []
    gsign = []
    lsign = []
    # i_sign = {}
    db = pymysql.connect(host="localhost",
                         user="root",
                         password="123456",
                         database="Ayh",
                         charset="utf8")
    print("database yes")
    cursor = db.cursor()

    # sql = "SELECT name,id from classes WHERE id = (SELECT cid FROM createSign WHERE id=(SELECT csid FROM sign WHERE
    # " \ "uid=(SELECT id FROM users WHERE openid = '%s')))" % openid
    sql1 = "SELECT csid FROM sign WHERE uid=(SELECT id FROM users WHERE openid = '%s' )" % openid
    # sql2 = "SELECT * FROM info inner join info1"
    try:
        cursor.execute(sql1)
        info = cursor.fetchall()
        for i in info:
            i_sign = {}
            print(i[0])
            i_sign["signid"] = i[0]
            sql2 = "SELECT name FROM classes WHERE id =  (SELECT cid FROM createSign WHERE id=%d)" % i[0]
            print(i[0])
            # db1 = pymysql.connect(host="localhost",
            #                       user="root",
            #                       password="123456",
            #                       database="ayh",
            #                       charset="utf8")
            print("database yes2")
            cursor.execute(sql2)
            # cur = db.cursor()
            # cur.execute(sql2)
            info1 = cursor.fetchall()
            for j in info1:
                print(j[0])
                i_sign["name"] = j[0]
            sign.append(i_sign)
            print(sign)
            # cursor.close()
            # db1.close()
        cursor.close()
        db.close()
        data = {
            "sign": sign,
            "psign": psign,
            "gsign": gsign,
            "lsign": lsign
        }
        print(data)
        return jsonify({"status": 200, "data": data})

    except Exception as e:
        print(e)
        db.rollback()
        cursor.close()
        db.close()
        return jsonify({"status": 500, "msg": 0})
